﻿using System;

namespace Infrastructure.Sockets.models
{
    /// <summary>
    /// 异步TcpListener TCP服务器事件参数类 
    /// </summary>
    public class AsyncEventArgs : EventArgs
    {
        /// <summary>
        /// 提示信息
        /// </summary>
        public string Msg;

        /// <summary>
        /// 客户端状态封装类
        /// </summary>
        public TcpClientState State;

        /// <summary>
        /// 是否已经处理过了
        /// </summary>
        public bool IsHandled { get; set; }

        /// <summary>
        /// 数据数组
        /// </summary>
        public byte[] BufferData => State?.BufferData ?? new byte[0];

        /// <summary>
        /// 
        /// </summary>
        /// <param name="msg"></param>
        public AsyncEventArgs(string msg)
        {
            Msg = msg;
            IsHandled = false;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="state"></param>
        public AsyncEventArgs(TcpClientState state)
        {
            State = state;
            IsHandled = false;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="state"></param>
        public AsyncEventArgs(string msg, TcpClientState state)
        {
            Msg = msg;
            State = state;
            IsHandled = false;
        }
    }
}
